const path = require('path');

function resolve(dir) {
	return path.join(__dirname, dir)
}
function getBaseUrl(){
	var url = ''
	switch (process.env.NODE_ENV){
		case 'test':
		case 'production':
			url = '/' + process.env.VUE_APP_NAME
			break;
	}
	return url + '/'
}
module.exports = {
	lintOnSave: true,
	chainWebpack: (config) => {
		config.resolve.alias
			.set('@', resolve('src'))
	},
	runtimeCompiler: true,
	publicPath: getBaseUrl(),// 对应后面`nginx`路径，这里添加的目的是其他静态资源文件统一前缀路径
	devServer: {
		proxy: {
			'/': {
				target: process.env.VUE_APP_URL,
				changeOrigin: true,
				ws: true,
			},
		},
		historyApiFallback: true,
		disableHostCheck: true,
	}
}
